package com.orange.quickback.system.controller.user.manage;

import com.orange.quickback.system.api.common.result.QBootResult;
import com.orange.quickback.system.controller.user.manage.views.QBootForm;
import com.orange.quickback.system.service.user.manage.QBootRolesMenuService;
import com.orange.quickback.system.service.user.manage.QBootRolesService;
import com.orange.quickback.system.service.user.manage.QBootUserService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "用户权限管理模块")
@RestController
@RequestMapping("/admin/")
public class AdminController {
    @Resource
    QBootUserService qBootUserService;
    @Resource
    QBootRolesService qBootRolesService;
    @Resource
    QBootRolesMenuService qBootRolesMenuService;
    @GetMapping("/getAllUserByPage")
    public QBootResult getAllUserByPage(@RequestParam int page,@RequestParam int size){
        return qBootUserService.getAllUsersByPage(page,size);
    }
    @GetMapping("/getAllRoleMenuByPage")
    public QBootResult getAllRoleMenuByPage(@RequestParam int page,@RequestParam int size){
        return qBootRolesService.getAllRolesMenu(page,size);
    }
    @GetMapping("/getAllRoles")
    public QBootResult getAllRoles(){
        return qBootRolesService.getAllRoles();
    }
    @PostMapping("/addNewPattern")
    public QBootResult addNewPattern(@RequestBody QBootForm qBootForm){
        return qBootRolesMenuService.addNewPattern(qBootForm.getRoles(),qBootForm.getPattern());
    }
    @PostMapping("/deleteRolesMenuById")
    public QBootResult deleteRolesMenuById(@RequestParam String id){
        return qBootRolesService.deleteRolesMenuById(Long.valueOf(id));
    }
}
